<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js">
    </script>
</head>

<body>
    <script>
        var app = angular.module('myApp',[]);
        // scope拼写错误也能导致有问题，页面显示{{mylocation}}
        app.controller('myserviceCtrl', function($scope, $location){
            $scope.mylocation = $location.absUrl();
        });

        // var app = angular.module('myApp', []);
        // app.controller('myCtrl', function($scope, $http) {
        //     $http.get("welcome.html").then(function (response) {
        //         $scope.myWelcome = response.data;
        //     });
        // });

        // var app = angular.module('myApp', []);
        app.controller('myserviceCtrl', function($scope, $timeout) {
            $scope.myHeader = "Hello World!";
            $timeout(function () {
                $scope.myHeader = "How are you today?";
            }, 2000);
        });

        var app = angular.module('myApp', []);
        app.controller('myCtrl', function($scope, $interval) {
            $scope.theTime = new Date().toLocaleTimeString();
            $interval(function () {
                $scope.theTime = new Date().toLocaleTimeString();
            }, 1000);
        });

        // 创建自定义服务
        app.service('hexafy', function() {
            this.myFunc = function (x) {
                return x.toString(16);
            }
        });

        app.filter('myFormat',['hexafy', function(hexafy) {
            return function(x) {
                return hexafy.myFunc(x);
            };
        }]);
    </script>
    <div ng-app='myApp' ng-controller="myserviceCtrl">
        url: {{mylocation}}<br>
        timeout:{{myHeader}}
    </div>

</body>

</html>